package com.sky.mapper.user;

import com.sky.pojo.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    /**
     * 动态条件查询
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);


    /**
     * 根据id更新数量
     * @param shoppingCart
     */
    @Update("update shopping_cart set number=#{number} where id=#{id}")
    void updateById(ShoppingCart shoppingCart);


    /**
     * 插入套餐
     * @param shoppingCart
     */
    void insert(ShoppingCart shoppingCart);


    /**
     * 根据用户id清空对应购物车
     * @param userId
     */
    @Delete("delete  from shopping_cart where user_id=#{userId} ")
    void clean(Long userId);


    /**
     * 查询所有菜品的烹饪时间
     * @param userId
     * @return
     */
    Integer getEstimatedDeliveryTime(Long userId);


    /**
     * 再来一单
     * @param shoppingCartList
     */
    void insertBatch(List<ShoppingCart> shoppingCartList);
}
